{extend name="base"/}
{block name="resources"}
{/block}
{block name="main"}

<!-- 搜索框 -->
<!--<div class="ns-single-filter-box">-->

    <!--<div class="layui-form">-->
        <!--<div class="layui-input-inline">-->
            <!--<input type="text" name="search" placeholder="请输入商品名称" class="layui-input" autocomplete="off">-->
            <!--<button type="button" class="layui-btn layui-btn-primary" lay-filter="search" lay-submit>-->
                <!--<i class="layui-icon">&#xe615;</i>-->
            <!--</button>-->
        <!--</div>-->
    <!--</div>-->
<!--</div>-->


<!-- 列表 -->
<table id="good_list" lay-filter="good_list"></table>



<!-- 商品 -->
<script type="text/html" id="goodIntro">
    <div class="ns-table-title">
        <div class="ns-title-pic">
            {{#  if(d.sku_image){  }}
            <img layer-src src="{{ns.img(d.sku_image.split(',')[0],'small')}}"/>
            {{#  }  }}
        </div>
        <div class="ns-title-content">
            <a href="javascript:;" class="ns-multi-line-hiding ns-text-color">{{d.sku_name}}</a>
        </div>
    </div>
</script>


{/block}
{block name="script"}
<script>
    var  form, table, laytpl;

    layui.use(['form', 'laytpl'], function() {
        form = layui.form;
        laytpl = layui.laytpl;
        form.render();

        table = new Table({
            elem: '#good_list',
            url: '{:addon_url("shop/goods/goodsbrowse")}',
            async : false,
            where: {'goods_id': "{$goods_id}"},
            parseData: function(res) {
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.count,
                    "data": res.data.list,
                };
            },
            cols: [
                [{
                    title: '商品',
                    unresize: 'false',
                    width: '30%',
                    templet: '#goodIntro'
                },{
                    title: '会员',
                    unresize: 'false',
                    width: '30%',
                    align: 'left',
                    templet: function(data) {
                        return data.nickname;
                    }
                }, {
                    title: '浏览时间',
                    unresize: 'false',
                    width: '20%',
                    align: 'left',
                    templet: function(data){
                        return ns.time_to_date(data.browse_time);
                    }
                }]
            ]
        });



        /**
         * 搜索功能
         */
        form.on('submit(search)', function(data) {
            table.reload({
                page: {
                    curr: 1
                },
                where: data.field
            });
        });
    });





</script>
{/block}